<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="h" uri="/syzg-html"%>
<% request.setAttribute("ctx", request.getContextPath()); %>
<!DOCTYPE html>
<html>
<body>
<div class="modal fade bs-example-modal-lg" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">修改信息</h4>
      </div>
      <div class="modal-body" id="modalCore">
        <form class="form-horizontal" role="form" id="aeForm" name="aeForm">
          <fieldset>
            <!-- generate code start -->
			<input type="hidden" id="type" name="type" value="${news.type}" class="form-control" />
            <div class="form-group">
              <label class="col-sm-2 control-label" for="id">ID</label>
              <div class="col-sm-3">
                <input type="text" id="id" name="id" value="${news.id}" class="form-control" readonly="readonly"/>
              </div>

              <label class="col-sm-2 control-label" for="newsColumnsId">所属栏目</label>
              <div class="col-sm-3">
               <%--  <input type="text" id="newsColumnsId" name="newsColumnsId"  value="${news.newsColumns.id}" class="form-control" /> --%>
                <input type="text" id="newsColumnsName" onclick="openColumns()"  value="${news.newsColumns.name}"  class="form-control" />
                <input type="hidden"  id="newsColumnsId"  name="newsColumns.id" value="${news.newsColumns.id}"  />
              </div>
            </div>

            <div class="form-group">
              <label class="col-sm-2 control-label" for="newstype">新闻分类</label>
              <div class="col-sm-3">
                <input type="text" id="newstype" name="newstype" onclick="openBasicData()" value="${news.newstype}" class="form-control" />
              </div>

              <label class="col-sm-2 control-label" for="title">新闻标题</label>
              <div class="col-sm-3">
                <input type="text" id="title" name="title" value="${news.title}" class="form-control" />
              </div>
            </div>

             <div class="form-group">
              <label class="col-sm-2 control-label" for="coverPath">封面图片</label>
              <div class="col-sm-3">
               <%--  <input type="text" id="coverPath" name="coverPath" value="${news.coverPath}" class="form-control" /> --%>
	               <div class="col-sm-3">
						<div style="border:solid 1px black; width: 200px;height: 200px">
							<img src="${ctx}/path/image/thumbnail/${news.coverPath}"  style="width: 100px;height: 100px;" alt="选择图片" onclick="doSelectPic()">
						</div>
						<input type="hidden" id="coverPath" name="coverPath" value="${news.coverPath}" />
					</div>
              </div>
            </div>

            <div class="form-group">
              <label class="col-sm-2 control-label" for="correspondent">通讯员</label>
              <div class="col-sm-3">
                <input type="text" id="correspondent" name="correspondent" value="${news.correspondent}" class="form-control" />
              </div>

              <label class="col-sm-2 control-label" for="photographer">摄影师</label>
              <div class="col-sm-3">
                <input type="text" id="photographer" name="photographer" value="${news.photographer}" class="form-control" />
              </div>
            </div>

            <div class="form-group">
              <label class="col-sm-2 control-label" for="editor">编辑</label>
              <div class="col-sm-3">
                <input type="text" id="editor" name="editor" value="${news.editor}" class="form-control" />
              </div>

              <label class="col-sm-2 control-label" for="keyword">关键字</label>
              <div class="col-sm-3">
                <input type="text" id="keyword" name="keyword" value="${news.keyword}" class="form-control" />
              </div>
            </div>

            <div class="form-group">
              <label class="col-sm-2 control-label" for="isTop">是否置顶</label>
              <div class="col-sm-3">
                    <select  id="isTop" name="isTop" class="form-control isTop"   >
                	<option value="0"  <c:if test="${news.isTop=='0'}"> selected</c:if>  >否</option>
                	<option value="1"  <c:if test="${news.isTop=='1'}"> selected</c:if>  >是 </option>
            	    </select>
            	   
            	 
              </div>

              <label class="col-sm-2 control-label" for="isStriking">是否醒目</label>
              <div class="col-sm-3">
                    <select name="isStriking" class="form-control" >
                	<option value="0"  <c:if test="${news.isStriking=='0'}"> selected</c:if> >否</option>
                	<option value="1"  <c:if test="${news.isStriking=='1'}"> selected</c:if> >是</option>
            	    </select>
              </div>
            </div>

            <div class="form-group">
              <label class="col-sm-2 control-label" for="isCarousel">是否轮播</label>
                <div class="col-sm-3">
                    <select name="isCarousel" class="form-control"  >
                	<option value="0"  <c:if test="${news.isCarousel=='0'}"> selected</c:if> >否</option>
                	<option value="1"  <c:if test="${news.isCarousel=='1'}"> selected</c:if> >是</option>
            	    </select>
              </div>
			
			 <label class="col-sm-2 control-label" for="showTime">开始展示时间</label>
              <div class="col-sm-3">
                 <input type="text" id="showTime" name="showTime" value='<fmt:formatDate value="${news.showTime}" pattern="yyyy-MM-dd HH:mm:ss" />' class="form-control" />
              </div> 
              
            </div>
            
              <div class="form-group">
              <label class="col-sm-2 control-label" for="content">新闻内容</label>
              <div class="col-sm-3">
                <textarea class="form-control"  id="content" name="content" rows="3">${news.content}</textarea>
               <%--  <input type="text" id="content" name="content" value="${news.content}" class="form-control" /> --%>
              </div>
          </div> 

			<!-- generate code end -->
          </fieldset>
        </form>
      </div>
        <div id="treeDlg"></div>
        <div id="imgDlg" ></div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary" onclick="submitSave('edit');">保存</button>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
$('#aeForm').bootstrapValidator({
  message: 'This value is not valid',
  feedbackIcons: {
      valid: 'glyphicon glyphicon-ok',
      invalid: 'glyphicon glyphicon-remove',
      validating: 'glyphicon glyphicon-refresh'
  },
  fields: {
      /*name: {
    	  group: '.col-sm-3',
          message: 'The username is not valid',
          validators: {
              notEmpty: {
                  message: 'The username is required and cannot be empty'
              },
              stringLength: {
                  min: 6,
                  max: 30,
                  message: 'The username must be more than 6 and less than 30 characters long'
              }
          }
      },
      email: {
    	  group: '.col-sm-3',
          validators: {
              emailAddress: {
                  message: 'The input is not a valid email address'
              }
          }
      }*/
  	}
}).on('success.form.bv', function(e, data) {
	FormFunction.submitSave('edit');
});

function openColumns(){
	ModalUtil.showModal('treeDlg', treeNewsColumnsViewUrl, 'treeNewsColumnsViewModal',function(){
		loadNewsColumnsData();
	});
}
function openBasicData(){
	ModalUtil.showModal('treeDlg', treeBasicDataViewUrl, 'treeBasicDataViewModal',function(){
		loadBasicDataData("newsType");
	});
}

function imageUpload(){
	FormFunction.showImageUpload();
}

function setColumnsValue(data){
	$("#newsColumnsId").val(data.id);
	$("#newsColumnsName").val(data.text);
}
function setBasicDataValue(data){
	$("#newstype").val(data.text);
	//$("#newsColumnsName").val(data.text);
}

</script>
</body>
</html>
